import time
from functools import wraps


def timethis(func):
    @wraps(func) #有了注解后, 元信息不会丢失
    def wrapper(*args,**kwargs):
        start = time.time()
        result = func(*args,**kwargs)
        end = time.time()
        print(func.__name__,end-start)
        return result
    return wrapper

@timethis
def countdown(n):
    '''
    Counts down
    '''
    print(n," start")
    while n > 0:
        n-=1
    print(" End")

countdown(100000)
print(countdown.__doc__)
#访问原始函数
orig_countdown = countdown.__wrapped__
orig_countdown(200000)